package zsw.Demo6;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.Scanner;
public class Main {
    public static void main(String[] args) throws Exception{
        Teacher teacher1 = new Teacher(2021310111,"王成刚","男","nothing",0,39);
        Teacher teacher2 =new Teacher(2021310222,"李春梅","女","nothing",0,35);
        Student student1 = new Student(2021310111,"张之巅","男","nothing",0,"大三");
        Student student2 = new Student(2021310222,"薇薇安","女","nothing",0,"大三");
        Course course1= new Course(2021310111,"离散数学","综2904","上午8：00","nothing",0,0);
        Course course2= new Course(2021310222,"雅思初级英语","教307","下午3：30","nothing",0,0);
        System.out.println(" | 欢迎来到选课系统 按任意键开始 | ");
        Scanner input1=new Scanner(System.in);
        String c1=input1.next();
        while(1==1) {
            System.out.println("按任意键会返回菜单| 1 老师开课 | 2 学生选课 | 3 学生退课 | 4 查看课表 | 5 保存文件 | 6 读取文件 | 7 结束 |按任意键会返回菜单");
            Scanner input2=new Scanner(System.in);
            int c2=input2.nextInt();
            if(c2==1){
                teacher1.tchoice(teacher1,teacher2,course1,course2);
            }
            if(c2==2){
                student1.choice(student1,student2,course1,course2);
            }
            if(c2==3){
                student1.nochoice(student1,student2,course1,course2);
            }
            if(c2==4){
                course1.Timetable(student1,student2,course1,course2);
            }
            if(c2==5) {
                System.out.println("| 输入保存路径 |");
                Scanner input3=new Scanner(System.in);
                String c3=input3.next();
                FileOutputStream fos = new FileOutputStream(c3);
                ObjectOutputStream oos = new ObjectOutputStream(fos);
                write sequence2=new write(teacher1.course,teacher2.course,teacher1.course1,
                        teacher2.course1, student1.course, student2.course, student1.course1,
                        student2.course1, course1.teacher, course2.teacher, course1.teacher1, course2.teacher1);
                oos.writeObject(sequence2);
                oos.close();
            }
            if(c2==6) {
                System.out.println("| 输入读取路径 |");
                Scanner input4=new Scanner(System.in);
                String c4=input4.next();
                FileInputStream inputStream = new FileInputStream(c4);
                ObjectInputStream mms = new ObjectInputStream(inputStream);
                write sequence1 = (write) mms.readObject();
                teacher1.course= sequence1.courseA;teacher2.course= sequence1.courseB;teacher1.course1=sequence1.courseC;
                teacher2.course1=sequence1.courseD;student1.course= sequence1.courseE;student2.course=sequence1.courseF;
                student1.course1= sequence1.courseG;student2.course1= sequence1.courseH;course1.course= sequence1.teacherI;
                course2.course= sequence1.teacherJ;course1.course1= sequence1.teacherK;course2.course1= sequence1.teacherL;
                mms.close();
            }
            if(c2==7){
                break;
            }
        }
    }
}





